//
//  WBDemoViewController.swift
//  小贝微博
//
//  Created by 汪波 on 2017/4/13.
//  Copyright © 2017年 Kevin. All rights reserved.
//

import UIKit

class WBDemoViewController: WBBaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //设置标题
        title = "第 \(navigationController?.childViewControllers.count ?? 0) 个"

    }
    // MARK: - 监听方法
    /// 继续push一个新的控制器
    @objc fileprivate func showNext() {
        let vc = WBDemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
}

extension WBDemoViewController {
    //重写父类方法
    override func setupUI() {
        //不要忘记super,不然背景颜色没有
        super.setupUI()
        //设置右侧的控制器
        //navigationItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", style: .plain, target: self, action: #selector(showNext))
        
//        let btn: UIButton = UIButton.cz_textButton("下一个", fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
//        
//        btn.addTarget(self, action: #selector(showNext), for: .touchUpInside)
//        
//        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
        
        //用自定义的遍历构造方法
        navItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", target: self, action: #selector(showNext))
    }
}
